package com.module.business.web;


import com.module.business.service.IUsersService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import springfox.documentation.annotations.ApiIgnore;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
//import org.flowable.task.api.Task;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author chengluqiang
 * @since 2019-03-04
 */
@RestController
@RequestMapping("/users")
public class UsersController {

    @Resource
    private IUsersService usersService;

    @GetMapping("/get/{id}")
    public String get(@PathVariable("id")String id){
        String msg1 = usersService.getMsg1(id);
        System.out.println("——getMsg1——"+msg1);
        return usersService.getMsg(id);
    }
    
    @GetMapping("/get2/{id}")
    public String get2(@PathVariable("id")String id){
        return usersService.getMsg2(id);
    }
    
    @GetMapping("/save/{id}/{val}")
    public String save(@PathVariable("id")String id,@PathVariable("val")String val){
        return usersService.save(id,val);
    }
    
    /**
     * 启动流程
     * @author chenluqiang
     * @date 2019年3月11日 下午4:24:44 
     * @param userId
     * @return
     *//*
    @GetMapping("/add/{userId}")
    public String add(@PathVariable("userId")String userId) {
    	return usersService.startProcess(userId);
    }
    *//**
     * 通过流程
     * @author chenluqiang
     * @date 2019年3月11日 下午4:25:36 
     * @param proId
     * @return
     *//*
    @GetMapping("/pass/{proId}")
    public String pass(@PathVariable("proId")String proId) {
    	return usersService.passProcess(proId);
    }
    *//**
     * 流程列表
     * @author chenluqiang
     * @date 2019年3月11日 下午4:26:09 
     * @param userId
     * @return
     *//*
    @GetMapping("/list/{userId}")
    public String list(@PathVariable("userId")String userId) {
    	return usersService.list(userId).toString();
    }
    
    *//**
     * 生成流程图
     *
     * @param processId 任务ID
     *//*
    @RequestMapping("/processDiagram/{processId}")
    public void genProcessDiagram(HttpServletResponse httpServletResponse,@PathVariable("processId")String processId) throws Exception {
        usersService.getProcessDiagram(httpServletResponse,processId);
    }*/
    
    /***
     * 远程调用
     */
    @Autowired
	RestTemplate restTemplate;
    @GetMapping("/restTest")
    @ApiOperation(value="restTemplate远程调用测试!!!")
    public String test() {
    	String str = restTemplate.getForObject("http://127.0.0.1:8080/users/get/1", String.class);
    	System.out.println(str);
    	return str;
    }
}

